function Star()
{
    this.radius = getStarRadius();
    this.speed = this.radius * 0.5;
    this.color = getStarColor( this.radius );  
    this.x = 0;
    this.y = -5;        
    this.lineWidth = 1;
}

Star.prototype.draw = function( context )
{
    context.save();

    context.translate( this.x, this.y );
  
    context.lineWidth = this.lineWidth;
    context.fillStyle = this.color;

    context.shadowBlur = 2 * this.radius;
    context.shadowOffsetX = 0;
    context.shadowOffsetY = 0;
    context.shadowColor = utils.colorToRGB( this.color, 0.5 );

    context.beginPath();

    context.arc( 0, 0, this.radius, 0, ( Math.PI * 2 ), true );

    context.closePath();
    context.fill();      

    context.restore();
};

function getStarsSky( numStars, stars, width, height )
{                
    var i = 0;                                                     
                      
    if ( stars.length == 0 )
    {   
        for ( i = 0; i < numStars; i++ )
        {
            stars[i] = new Star();
            stars[i].x = getRandomArbitary( 0, width );
            stars[i].y = getRandomArbitary( 0, height );
        }
    }
    for ( i = 0; i < numStars; i++ )
    {                                                          
        stars[i].y += stars[i].speed;
        if ( stars[i].y > height )
        {
            stars[i].y = -2 * stars[i].radius;
            stars[i].x = getRandomArbitary( 0, width ); 
        }                             
    }
    return stars;
}

function getStarRadius()
{       
    var radius = Math.round( getRandomArbitary( 1, 100 ) );
    radius = ( radius >= 1 && radius <= 60 ) ? 1 : radius;
    radius = ( radius > 60 && radius <= 85 ) ? 2 : radius;
    radius = ( radius > 85 && radius <= 93 ) ? 3 : radius;
    radius = ( radius > 93 && radius <= 100 ) ? 4 : radius;
    return radius;
}

function getStarColor( radius )
{
    var color = "#000000";

    switch( radius )
    {
      case 4:
        color = "#9AAFFF";
        break;
      case 3:
        color = "#D6F8A1";
        break;
      case 2:
        color = "#E88D24";
        break;
      case 1:
        color = "#6B1504";
        break;
    }
    return color;
}
